package com.example.service.impl;

import com.example.mapper.minorDefectsRecordMapp;
import com.example.pojo.minorDefectsRecordPojo;
import com.example.service.minorDefectsRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

/**
 * ClassName:minorDefectsRecordImpl
 * Package:com.example.service.impl
 * Description:
 *
 * @Author：牧星苑
 * @Create 2025/10/7 14:25
 * @Version 1.0
 */
@Service
public class minorDefectsRecordImpl implements minorDefectsRecordService {
    @Autowired
    private minorDefectsRecordMapp minorDefectsRecordMapp;
    //插入一行微小缺陷
    public void insertOne(minorDefectsRecordPojo pojo){
        pojo.setCreate_time(LocalDateTime.now());
        pojo.setUpdate_time(LocalDateTime.now());
        minorDefectsRecordMapp.insertOne(pojo);
    }

    //修改一行微小缺陷
    public void editOneById(minorDefectsRecordPojo pojo){
        pojo.setUpdate_time(LocalDateTime.now());
        minorDefectsRecordMapp.editOneById(pojo);
    }

    //根据分页查询微小缺陷数据
    public List<minorDefectsRecordPojo> queryByPage(Map<String, Object> map){
        Integer page =(Integer) map.get("page");
        Integer size=(Integer) map.get("size");
        String workshop=(String) map.get("workshop");
        Integer startRow=page*size;
        List<minorDefectsRecordPojo> minorDefectsRecordPojos=minorDefectsRecordMapp.queryByPage(startRow, size, workshop);
        return minorDefectsRecordPojos;
    }

    //查询所有微小缺陷条数
    public Integer queryQuantity(Map<String, Object> map) {
        String workshop = (String) map.get("workshop");
        Integer quantity = minorDefectsRecordMapp.queryQuantity(workshop);
        return quantity;
    }
}
